<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    // 数组的解构赋值
    const arr = [1, 2, 'a'];
    let [a, b, c] = arr;
    console.log(a, b, c); // 1 2 'a'

    // 对象的解构赋值
    const lin = {
        name: '林志颖',
        tags: ['车手', '歌手', '小旋风', '演员']
    };
    let {name, tags} = lin;
    console.log(name, tags); // 林志颖 (4) ['车手', '歌手', '小旋风', '演员']

    //复杂解构
    let wangfei = {
        name: '王菲',
        age: 18,
        songs: ['红豆', '流年', '暧昧', '传奇'],
        history: [
            {name: '窦唯'},
            {name: '李亚鹏'},
            {name: '谢霆锋'}
        ]
    };
    let {songs: [one, two, three], history: [first, second, third]} = wangfei;
    console.log(one, two, three, first, second, third);
    // 红豆 流年 暧昧 {name: '窦唯'} {name: '李亚鹏'} {name: '谢霆锋'}


</script>
</html>